

 
/* 
 * ---------------------------------------------------------------------
 * Google suggest client-side API - hack =)
 * ---------------------------------------------------------------------
 */

window.google.ac = [];
window.google.ac.h  = google_suggest_process;

/*
 * Global var to be altered by users before calling google_suggest()
 */
google_suggest_callback = null;

function google_suggest_parse(json) {

    rval = [];

    if (json == null) {
        return null;
    }

    if (json.length < 1) {
        return null;
    }

    temp = json[1];

    for (z = 0; z < temp.length; z++) {
        str = temp[z][0];
        rval.push(str);
    }

    return rval;
}

function google_suggest_process(json) {

    if (google_suggest_callback != null) {

        array = google_suggest_parse(json);
        
        if (array != null) google_suggest_callback(array);

    }
}


function google_suggest(q) {

    $.getScript("http://google.com/s?q="+escape(q));

}



